<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 200px;
            height: 200px;
        }
        img{
            width: 50px;
            height: 50px;
        }
    </style>
</head>
<body>
    图片上传预览：<input type="file" multiple onchange="upload(event)"/>
    <div id="output">

    </div>
</body>
<script>
    const outputDOM = document.getElementById('output');
    const fragment = document.createDocumentFragment(); //创建虚拟节点对象(文档片段)
    function upload(event){
        let files = event.target.files;
        for(let i = 0; i <files.length;i++){
            let url = window.URL.createObjectURL(files[0])
            let img = document.createElement('img');
            img.src = url;
            fragment.appendChild(img);
        }
        outputDOM.appendChild(fragment);
    }
</script>
</html>